<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"
    import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>填寫預借記錄</title>
</head>
<body>
<% if(session.getAttribute("access") == "y" ){
String fname=new String(request.getParameter("f_name").getBytes("iso-8859-1"),"utf-8");
String book=new String(request.getParameter("book_date").getBytes("iso-8859-1"),"utf-8");
 %>
<table width="750" border="0" align="center">
  <tr>
    <td width="30" rowspan="4"><jsp:include page="../frameset/left.jsp" flush="true" ></jsp:include></td>
    <td colspan="2"><jsp:include page="../frameset/top.jsp" flush="true" ></jsp:include></td>
    <td width="40" rowspan="4"><jsp:include page="../frameset/right.jsp" flush="true" ></jsp:include></td>
  </tr>
  <tr>
    <td rowspan="2"><jsp:include page="../frameset/mean.jsp" flush="true" ></jsp:include></td>
    <td height="32"><jsp:include page="../frameset/book_mean.jsp" flush="true" ></jsp:include></td>
  </tr>
  <tr>
    <td>
    <table width="500" border="0" align="center">
  <tr>
    <td><form id="form1" name="form1" method="post" action="do_addBook.jsp">
	<table width="400" border="1" align="center">
  <tr>
    <td width="27%">設備編號</td>
    <td width="73%"><%=request.getParameter("f_id") %><input type="hidden" name="f_id" value="<%=request.getParameter("f_id")%>"></td>
  </tr>
  <tr>
    <td>設備名稱</td>
    <td><%=fname %><input type="hidden" name="f_name" value="<%=fname%>"></td>
  </tr>

  <tr>
    <td>預借日期</td>
    <td><%=book %><input type="hidden" name="book_date" value="<%=book%>"></td>
  </tr>
  <tr>
    <td>借用時段</td>
    <td>
    <% 
	String[] book_times = request.getParameterValues("book_time");
	String b_time="";
	for(int i = 0; i < book_times.length; i++) {
		b_time+=book_times[i];
	}
	for(int i = 0; i < book_times.length; i++) {
		if(book_times[i].equalsIgnoreCase("a")){
			out.print("上午;");
		}else if(book_times[i].equalsIgnoreCase("b")){
			out.print("中午;");
		}else if(book_times[i].equalsIgnoreCase("c")){
			out.print("下午;");
		}else if(book_times[i].equalsIgnoreCase("d")){
			out.print("晚上;");
		}
    }
	%>
	<input type="hidden" name="bt_class" value="<%=b_time%>">
</td>
  </tr>
  <tr>
    <td>預借者</td>
    <td><%=session.getAttribute("accessid")%><input type="hidden" name="m_id" value="<%=session.getAttribute("accessid")%>"></td>
  </tr>
  <tr>
    <td>預借理由</td>
    <td><textarea name="reason" cols="30" rows="5"></textarea></td>
  </tr>
  <tr align="center">
    <td colspan="2" ><input name="reset" type="reset" value="重新填寫" /><input name="add" type="submit" onClick="return formCheck()" id="set" value="新增" /></td>
   
  </tr>
</table>
    </form>
    </td>
  </tr>

</table>
    </td>
  </tr>
  <tr>
    <td colspan="2"></td>
  </tr>
</table>
<%
  }
  else{
  	response.sendRedirect("../index.jsp"); //若沒有登入則回到index.jsp
  } 
  %>
</body>
</html>